package com.yanfan.zutai.controller;

import com.yanfan.common.annotation.Log;
import com.yanfan.common.core.controller.BaseController;
import com.yanfan.common.core.domain.AjaxResult;
import com.yanfan.common.core.page.TableDataInfo;
import com.yanfan.common.enums.BusinessType;
import com.yanfan.common.utils.poi.ExcelUtil;
import com.yanfan.zutai.aop.SysInitData;
import com.yanfan.zutai.aop.SysInitUpdateData;
import com.yanfan.zutai.aop.SysQueryData;
import com.yanfan.zutai.domain.BDeviceComConfig;
import com.yanfan.zutai.service.IBDeviceComConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 通讯口配置Controller
 *
 * @author ruoyi
 * @date 2023-06-10
 */
@RestController
@RequestMapping("/zutai/bDeviceComConfig")
public class BDeviceComConfigController extends BaseController {
    @Autowired
    private IBDeviceComConfigService bDeviceComConfigService;

    /**
     * 查询通讯口配置列表
     */
    //@PreAuthorize("@ss.hasPermi('ghxx:bDeviceComConfig:list')")
    @GetMapping("/list")
    @SysQueryData
    public TableDataInfo list(BDeviceComConfig bDeviceComConfig) {
        startPage();
        List<BDeviceComConfig> list = bDeviceComConfigService.selectBDeviceComConfigList(bDeviceComConfig);
        return getDataTable(list);
    }

    /**
     * 导出通讯口配置列表
     */
    //@PreAuthorize("@ss.hasPermi('ghxx:bDeviceComConfig:export')")
    @Log(title = "通讯口配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BDeviceComConfig bDeviceComConfig) {
        List<BDeviceComConfig> list = bDeviceComConfigService.selectBDeviceComConfigList(bDeviceComConfig);
        ExcelUtil<BDeviceComConfig> util = new ExcelUtil<BDeviceComConfig>(BDeviceComConfig.class);
        util.exportExcel(response, list, "通讯口配置数据");
    }

    /**
     * 获取通讯口配置详细信息
     */
    //@PreAuthorize("@ss.hasPermi('ghxx:bDeviceComConfig:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(bDeviceComConfigService.selectBDeviceComConfigById(id));
    }

    /**
     * 新增通讯口配置
     */
    //@PreAuthorize("@ss.hasPermi('ghxx:bDeviceComConfig:add')")
    @Log(title = "通讯口配置", businessType = BusinessType.INSERT)
    @PostMapping
    @SysInitData
    public AjaxResult add(@RequestBody BDeviceComConfig bDeviceComConfig) {
        return toAjax(bDeviceComConfigService.insertBDeviceComConfig(bDeviceComConfig));
    }

    /**
     * 修改通讯口配置
     */
    //@PreAuthorize("@ss.hasPermi('ghxx:bDeviceComConfig:edit')")
    @Log(title = "通讯口配置", businessType = BusinessType.UPDATE)
    @PutMapping
    @SysInitUpdateData
    public AjaxResult edit(@RequestBody BDeviceComConfig bDeviceComConfig) {
        return toAjax(bDeviceComConfigService.updateBDeviceComConfig(bDeviceComConfig));
    }

    /**
     * 删除通讯口配置
     */
    //@PreAuthorize("@ss.hasPermi('ghxx:bDeviceComConfig:remove')")
    @Log(title = "通讯口配置", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(bDeviceComConfigService.deleteBDeviceComConfigByIds(ids));
    }
}
